<?php

namespace App\Http\Controllers\Front;

use App\Http\Controllers\Controller;
use App\Model\Aboot\Wishlist;
use Illuminate\Http\Request;

class WishlistController extends Controller
{
    public function index()
    {
        $wishlists = Wishlist::where('user_id', auth()->id())->get();
         
        return view('front.wishlist.index', ['wishlistP'=>$wishlists]);
    }

    public function create(Request $request)
    {
        Wishlist::create([
                  'user_id'=> auth()->id(),
                  'product_id' => $request->product_id
            ]);
        return back();
    }

    public function destroy($id)
    {
        Wishlist::find($id)->delete();
        return back();
    }
}
